<?php

use zkc\gii\generators\commonmodel\Generator;

/* @var $this yii\web\View */
/* @var $form yii\widgets\ActiveForm */
/* @var $generator yii\gii\generators\model\Generator */

echo $form->field($generator, 'tableName')->textInput(['table_prefix' => $generator->getTablePrefix()]);
echo $form->field($generator, 'modelClass');
echo $form->field($generator, 'ns');
echo $form->field($generator, 'baseClass');
echo $form->field($generator, 'db');
echo $form->field($generator, 'useTablePrefix')->checkbox();
//echo $form->field($generator, 'generateRelations')->dropDownList([
//	Generator::RELATIONS_NONE        => 'No relations',
//	Generator::RELATIONS_ALL         => 'All relations',
//	Generator::RELATIONS_ALL_INVERSE => 'All relations with inverse',
//]);
echo $form->field($generator, 'generateLabelsFromComments')->checkbox();
//echo $form->field($generator, 'generateQuery')->checkbox();
//echo $form->field($generator, 'queryNs');
//echo $form->field($generator, 'queryClass');
//echo $form->field($generator, 'queryBaseClass');
echo $form->field($generator, 'enableI18N')->checkbox();
echo $form->field($generator, 'messageCategory');
echo $form->field($generator, 'useSchemaName')->checkbox();

?>
<?php \common\widgets\JsBlock::begin() ?>
<script>
	$(function () {
		var tablename = $('#generator-tablename');
		var modelClass = $('#generator-modelclass');
		var ns = $('#generator-ns');
		var baseClass = $('#generator-baseclass');

		var change_func = function() {
			var _ns = ns.val();
			var _modelClass = modelClass.val();
				var moduleName = Inflector.id2camel(moduleId);
				if (!tablename.val()) {
					tablename.val(moduleId + '_');
				}

				//if (!baseClass.val()) {
				baseClass.val('common\\base\\BaseModel');
				//}
		};

		// modelClass.change(change_func);
		// ns.change(change_func);

		tablename.blur(function () {
			var tableId = tablename.val();
			var tableName2 = Inflector.id2camel(tableId);

			//if (!modelClass.val()) {
			modelClass.val(tableName2);
			//}
		});
	});
</script>
<?php \common\widgets\JsBlock::end() ?>






<?php

if($generator->hasErrors()) {
	echo '错误: ';
	var_dump($generator->errors);
}

?>










